package com.janwen.spring.jdbc.datasource;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;

@Component
public class AbstractNamedParameterJdbcTemplate {

	
	@Autowired
	@Qualifier("abstractNamedParameterJdbcTemplate")
	private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

	public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() {
		return namedParameterJdbcTemplate;
	}
	
	public Long getLastInsertId(){
		String sql ="select last_insert_id()";
		return getNamedParameterJdbcTemplate().queryForLong(sql, new HashMap<String, String>());
	}
	
}
